package com.ruoyi.swla2.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.swla2.domain.BasicDma;
import com.ruoyi.swla2.domain.Zone;
import com.ruoyi.swla2.service.IZoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dashboard")
public class DashboardController extends BaseController {

    @Autowired
    private IZoneService zoneService;

    /**
     * 查询DMA配置列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:freezeDfq:list')")
    @GetMapping("/getOverviewData")
    public AjaxResult getOverviewData(BasicDma basicDma) {
        List<Zone> zoneList =  zoneService.selectZoneList(new Zone());
        long dmaCount = zoneList.stream().filter(item->"2".equals(item.getLevelType())).count();
        long dyhCount = zoneList.stream().filter(item->"3".equals(item.getLevelType())).count();

        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("dmaCount", dmaCount);
        resultMap.put("dyhCount", dyhCount);
        return success(resultMap);
    }

}
